// source --> https://emettorah.com/wp-content/plugins/wp-yt-import/modules/js/front.js?ver=5.3.15 jQuery(document).ready( function($){ // speaker set up if( $('#speaker_set_up').length > 0 ){ $('#fld_2758980_4').val( $('#speaker_set_up').val() ); } $('#show-comments').click(function(){ $('.comments_scroller .comment_content').slideToggle(); $('.comments_scroller .comment_title .fa').toggleClass('fa-chevron-up fa-chevron-down'); }) // - 1.78 is the aspect ratio of the video // - This will work if your video is 1920 x 1080 // - To find this value divide the video's native width by the height eg 1920/1080 = 1.78 var aspectRatio = 1.78; var video = $('#videoWithJs iframe'); var videoHeight = video.outerHeight(); var newWidth = videoHeight*aspectRatio; var halfNewWidth = newWidth/2; video.css({"width":newWidth+"px","left":"50%","margin-left":"-"+halfNewWidth+"px"}); console.log('ex1'); $(window).on('resize', function() { // Same code as on load var aspectRatio = 1.78; var video = $('#videoWithJs iframe'); var videoHeight = video.outerHeight(); var newWidth = videoHeight*aspectRatio; var halfNewWidth = newWidth/2; video.css({"width":newWidth+"px","left":"50%","margin-left":"-"+halfNewWidth+"px"}); console.log('ex1'); }); $('.output_type.grid').click(function(){ $('.output_type.table').removeClass('active'); $('.output_type.grid').addClass('active'); $('.main_content_block.videos_list').removeClass('table_output'); }) $('.output_type.table').click(function(){ $('.output_type.grid').addClass('active'); $('.output_type.table').removeClass('active'); $('.main_content_block.videos_list').addClass('table_output'); }) $('.owl-carousel').each(function(){ var amount = 5; if( $(this).attr('data-cols') ){ var amount = $(this).attr('data-cols'); } var autoplay = false; if( $(this).attr('data-autoplay') ){ var autoplay = $(this).attr('data-autoplay'); } var time = 1000; if( $(this).attr('data-time') ){ var time = $(this).attr('data-time'); } console.log( 'amount' ); console.log( amount ); $(this).owlCarousel({ loop:true, margin:10, nav:true, autoplay:autoplay, autoplaySpeed : 1000, items:amount, navText:['',''], responsive:{ 0:{ items:1 }, 600:{ items:3 }, 1000:{ items:amount }, } }) }) $('.single_tag').click(function(){ var this_slug = $(this).attr('data-slug'); $('.main_content_block .single_video').hide(); $('.tag_'+this_slug).fadeIn(); }) $('.show_all').click(function(){ $('.main_content_block .single_video').show(); }) var select_1_slug ; $('#cat_selector').change(function(){ var this_slug = $(this).val(); select_1_slug = this_slug; if( this_slug == '0' || this_slug == '' ){ $('.main_content_block .single_video').show(); $('.col_subcategory').fadeOut(); $('#cat_selector_2').val('0'); }else{ $('#cat_selector_2 option').show(); $('#cat_selector_2').val( '0' ); $('.main_content_block .single_video').hide(); $('.tag_'+this_slug).fadeIn(); var visible_tags = []; $('.tag_'+this_slug).each(function(){ var all_classes = $(this).attr('class').split(' '); $.each( all_classes, function( index, value ){ if ( value.indexOf('tag_') > -1) { visible_tags.push( value ); } }) }) visible_tags = visible_tags.filter( onlyUnique ); console.log( visible_tags ); $('#cat_selector_2 option').each(function(){ if( visible_tags.indexOf( 'tag_'+$(this).attr('value') ) != -1 || $(this).attr('value') == '0' ){ }else{ $(this).hide(); } }) $('.col_subcategory').fadeIn(); } }) $('#cat_selector_2').change(function(){ if( $(this).val() == '0' ){ $('.tag_'+select_1_slug).fadeIn(); }else{ console.log( '.tag_'+select_1_slug+' .tag_'+$(this).val() ); $('.main_content_block .single_video' ).hide(); $('.tag_'+select_1_slug+'.tag_'+$(this).val() ).fadeIn(); } }) function onlyUnique(value, index, self) { return self.indexOf(value) === index; } $('.order_by_date').click(function(e){ $('.order_by_date').addClass('active'); $('.order_by_title').removeClass('active'); e.preventDefault(); $(".main_content_block.videos_list").hide(); var divList = $(".main_content_block.videos_list .single_video"); divList.sort(function(b,a){ return $(a).data("date")-$(b).data("date") }); $(".main_content_block.videos_list").html(divList); $(".main_content_block.videos_list").fadeIn(); }) $('.order_by_title').click(function(e){ $('.order_by_date').removeClass('active'); $('.order_by_title').addClass('active'); e.preventDefault(); $(".main_content_block.videos_list").hide(); var alphabeticallyOrderedDivs = $('.main_content_block.videos_list .single_video'); alphabeticallyOrderedDivs.sort(function(a, b) { return String.prototype.localeCompare.call($(a).data('title').toLowerCase(), $(b).data('title').toLowerCase()); }); $(".main_content_block.videos_list").html( alphabeticallyOrderedDivs );; $(".main_content_block.videos_list").fadeIn(); }) $(window).scroll(function(){ var x = $(".stickysidebar").offset(); if( $(".single-yt_video_playlist #sidebar").length > 0 || $(".tax-yt_video_tag #sidebar").length > 0 ){ var x = $(".top_big_bar"); //stickysidebarfloat var window_offset = x.offset().top - $(window).scrollTop(); if( window_offset <= 0 ){ $("#sidebar").addClass('stickysidebarfloat'); }else{ $("#sidebar").removeClass('stickysidebarfloat'); } console.log( "Top: " + window_offset ); } /* .single-yt_video #sidebar, */ if( $(".page-id-50419 #sidebar").length > 0 ){ var x = $("#left-area"); //stickysidebarfloat var window_offset = x.offset().top - $(window).scrollTop(); if( window_offset <= 0 ){ $("#sidebar").addClass('stickysidebarfloat'); }else{ $("#sidebar").removeClass('stickysidebarfloat'); } console.log( "Top: " + window_offset ); } if( $(".single-yt_video #sidebar").length > 0 ){ var x = $("#sidebar"); //stickysidebarfloat var window_offset = x.offset().top - $(window).scrollTop(); if( window_offset <= 0 ){ console.log( "Adding class "); $("#ubermenu_navigation_widget-2").addClass('stickysidebarfloat_single_post'); }else{ $("#ubermenu_navigation_widget-2").removeClass('stickysidebarfloat_single_post'); } console.log( "Top: " + window_offset ); } }); // show prater listStyleType // palylit filter $('#filter_topics').change(function(){ var id = $(this).val(); $('.main_content_block .single_video').each(function(){ if( $(this).hasClass('tag_'+id ) ){ $(this).fadeIn(); }else{ $(this).fadeOut(); } }) if( id == '0' ){ $('.main_content_block .single_video').fadeIn(); } }) // palylit filter $('#filter_playlist').change(function(){ var id = $(this).val(); $('.main_content_block .single_video').each(function(){ var this_title = $(this).attr('data-title'); var this_content = $(this).attr('data-content'); if( $(this).hasClass('speaker_'+id ) ){ $(this).fadeIn(); }else{ $(this).fadeOut(); } }) if( id == '0' ){ $('.main_content_block .single_video').fadeIn(); } }) //expand search bar $('.search_icon_block').click(function(){ $('.search_block ').toggleClass('uncollapsed'); $('.search_block .video_search').focus(); }) // process search $('.video_search').on('keyup', function (e) { if (e.keyCode === 13) { var search_term = $('.video_search').val(); search_term = search_term.toLowerCase(); //make search $('.main_content_block .single_video').each(function(){ var this_title = $(this).attr('data-title'); var this_content = $(this).attr('data-content'); if( ( this_title.toLowerCase().indexOf( search_term ) != -1 ) || ( this_content.toLowerCase().indexOf( search_term ) != -1 ) ){ $(this).fadeIn(); }else{ $(this).fadeOut(); } }) } }); // video blocks sizing if( $('.main_content_block.videos_list').length > 0 ){ var maxHeight = Math.max.apply(null, $(".main_content_block.videos_list .single_video").map(function () { return $(this).height(); }).get()); console.log('maxHeight' + maxHeight); //$(".videos_list:not(.featured_block) .single_video").css('height', maxHeight+'px' ); } var typingTimer; //timer identifier var doneTypingInterval = 5000; // autocomplete START function autocomplete(inp, arr) { /*the autocomplete function takes two arguments, the text field element and an array of possible autocompleted values:*/ var currentFocus; /*execute a function when someone writes in the text field:*/ var click_time; inp.addEventListener("input", function(e) { var a, b, i, val = this.value; /*close any already open lists of autocompleted values*/ var this_pnt = this; if( val.length < 3 ){ return true; } clearTimeout(typingTimer); typingTimer = setTimeout(function(){ console.log('make call'); var data = { search : val, action : 'make_ajax_search', security: wyi_local_data.nonce } jQuery.ajax({url: wyi_local_data.ajaxurl, type: 'POST', data: data, beforeSend: function(msg){ jQuery('#s').attr('disabled', true); jQuery('#st').attr('disabled', true); jQuery('#s').addClass('loading'); jQuery('#st').addClass('loading'); }, success: function(msg){ console.log( msg ); jQuery('#s').attr('disabled', false); jQuery('#s').removeClass('loading'); jQuery('#st').attr('disabled', false); jQuery('#st').removeClass('loading'); var obj = jQuery.parseJSON( msg ); if( obj.result == 'success' ){ closeAllLists(); if (!val) { return false;} currentFocus = -1; /*create a DIV element that will contain the items (values):*/ a = document.createElement("DIV"); a.setAttribute("id", this_pnt.id + "autocomplete-list"); a.setAttribute("class", "autocomplete-items"); /*append the DIV element as a child of the autocomplete container:*/ this_pnt.parentNode.appendChild(a); /*for each item in the array...*/ for (i = 0; i < obj.data.length; i++) { /*check if the item starts with the same letters as the text field value:*/ //if (arr[i].substr(0, val.length).toUpperCase() == val.toUpperCase()) { /*create a DIV element for each matching element:*/ b = document.createElement("DIV"); /*make the matching letters bold:*/ //b.innerHTML = "" + arr[i].substr(0, val.length) + ""; //b.innerHTML += arr[i].substr(val.length); /*insert a input field that will hold the current array item's value:*/ //b.innerHTML += ""; b.innerHTML = "
"+obj.data[i].title+"
"+obj.data[i].tags+"
" /*execute a function when someone clicks on the item value (DIV element):*/ b.addEventListener("click", function(e) { /*insert the value for the autocomplete text field:*/ inp.value = this_pnt.getElementsByTagName("input")[0].value; /*close the list of autocompleted values, (or any other open lists of autocompleted values:*/ closeAllLists(); }); a.appendChild(b); //} } }else{ } inp.focus(); } , error: function(msg) { } }); }, 1000) }); /*execute a function presses a key on the keyboard:*/ inp.addEventListener("keydown", function(e) { var x = document.getElementById(this.id + "autocomplete-list"); if (x) x = x.getElementsByTagName("div"); if (e.keyCode == 40) { /*If the arrow DOWN key is pressed, increase the currentFocus variable:*/ currentFocus++; /*and and make the current item more visible:*/ addActive(x); } else if (e.keyCode == 38) { //up /*If the arrow UP key is pressed, decrease the currentFocus variable:*/ currentFocus--; /*and and make the current item more visible:*/ addActive(x); } else if (e.keyCode == 13) { /*If the ENTER key is pressed, prevent the form from being submitted,*/ // e.preventDefault(); if (currentFocus > -1) { /*and simulate a click on the "active" item:*/ if (x) x[currentFocus].click(); } } }); function addActive(x) { /*a function to classify an item as "active":*/ if (!x) return false; /*start by removing the "active" class on all items:*/ removeActive(x); if (currentFocus >= x.length) currentFocus = 0; if (currentFocus < 0) currentFocus = (x.length - 1); /*add class "autocomplete-active":*/ x[currentFocus].classList.add("autocomplete-active"); } function removeActive(x) { /*a function to remove the "active" class from all autocomplete items:*/ for (var i = 0; i < x.length; i++) { x[i].classList.remove("autocomplete-active"); } } function closeAllLists(elmnt) { /*close all autocomplete lists in the document, except the one passed as an argument:*/ var x = document.getElementsByClassName("autocomplete-items"); for (var i = 0; i < x.length; i++) { if (elmnt != x[i] && elmnt != inp) { x[i].parentNode.removeChild(x[i]); } } } /*execute a function when someone clicks in the document:*/ document.addEventListener("click", function (e) { closeAllLists(e.target); }); } var countries = ["Afghanistan","Albania","Algeria","Andorra","Angola","Anguilla","Antigua & Barbuda","Argentina","Armenia","Aruba","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia","Bosnia & Herzegovina","Botswana","Brazil","British Virgin Islands","Brunei","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Canada","Cape Verde","Cayman Islands","Central Arfrican Republic","Chad","Chile","China","Colombia","Congo","Cook Islands","Costa Rica","Cote D Ivoire","Croatia","Cuba","Curacao","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","Ecuador","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia","Ethiopia","Falkland Islands","Faroe Islands","Fiji","Finland","France","French Polynesia","French West Indies","Gabon","Gambia","Georgia","Germany","Ghana","Gibraltar","Greece","Greenland","Grenada","Guam","Guatemala","Guernsey","Guinea","Guinea Bissau","Guyana","Haiti","Honduras","Hong Kong","Hungary","Iceland","India","Indonesia","Iran","Iraq","Ireland","Isle of Man","Israel","Italy","Jamaica","Japan","Jersey","Jordan","Kazakhstan","Kenya","Kiribati","Kosovo","Kuwait","Kyrgyzstan","Laos","Latvia","Lebanon","Lesotho","Liberia","Libya","Liechtenstein","Lithuania","Luxembourg","Macau","Macedonia","Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Marshall Islands","Mauritania","Mauritius","Mexico","Micronesia","Moldova","Monaco","Mongolia","Montenegro","Montserrat","Morocco","Mozambique","Myanmar","Namibia","Nauro","Nepal","Netherlands","Netherlands Antilles","New Caledonia","New Zealand","Nicaragua","Niger","Nigeria","North Korea","Norway","Oman","Pakistan","Palau","Palestine","Panama","Papua New Guinea","Paraguay","Peru","Philippines","Poland","Portugal","Puerto Rico","Qatar","Reunion","Romania","Russia","Rwanda","Saint Pierre & Miquelon","Samoa","San Marino","Sao Tome and Principe","Saudi Arabia","Senegal","Serbia","Seychelles","Sierra Leone","Singapore","Slovakia","Slovenia","Solomon Islands","Somalia","South Africa","South Korea","South Sudan","Spain","Sri Lanka","St Kitts & Nevis","St Lucia","St Vincent","Sudan","Suriname","Swaziland","Sweden","Switzerland","Syria","Taiwan","Tajikistan","Tanzania","Thailand","Timor L'Este","Togo","Tonga","Trinidad & Tobago","Tunisia","Turkey","Turkmenistan","Turks & Caicos","Tuvalu","Uganda","Ukraine","United Arab Emirates","United Kingdom","United States of America","Uruguay","Uzbekistan","Vanuatu","Vatican City","Venezuela","Vietnam","Virgin Islands (US)","Yemen","Zambia","Zimbabwe"]; if( $("#s").length > 0 ){ autocomplete(document.getElementById("s"), countries); } if( $("#st").length > 0 ){ autocomplete(document.getElementById("st"), countries); } //form submit // autocomplete END }) // global end;